package com.lenovo.newsapp.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lenovo.newsapp.R;
import com.lenovo.newsapp.model.Comment;
import com.lenovo.newsapp.util.Const;

public class CommentListAdapter extends BaseArrayAdapter<Comment> {

	private ViewHolder holder;
	//
//	private AsyncImageLoader imgLoader;
//
	public CommentListAdapter(Context context, ArrayList<Comment> list) {
		super(context, list, null);
		//imgLoader = new AsyncImageLoader(context);
	}
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.comment_list_item,null);
			holder.userName = (TextView) convertView.findViewById(R.id.comment_item_username);
			holder.time = (TextView) convertView.findViewById(R.id.comment_item_time);
			holder.upsNumber = (TextView) convertView.findViewById(R.id.comment_upsnumber);
			holder.commentDetail = (TextView) convertView.findViewById(R.id.comment_list_item_comment_detail);
		}
		Comment item = (Comment) getItem(position);
		Log.v(Const.DEBUG,"position--"+ position);
		
		holder.userName.setText(item.getUserName());
		holder.commentDetail.setText(item.getCommentContent());
		holder.userName.setText(item.getUserName());
		holder.time.setText(item.getLastUpdateTime());

		return convertView;
	}

	static class ViewHolder {
		TextView userName;
		TextView upsNumber;
		TextView commentDetail;
		TextView time;
	}

}
